- import_playbook: "/srv/web/infra/ansible/playbooks/include/virt-create.yml myhosts=pkgs-stg:pkgs02.phx2.fedoraproject.org"

- name: make the box be real
  hosts: pkgs-stg:pkgs02.phx2.fedoraproject.org
  user: root
  gather_facts: True

  vars_files:
  - /srv/web/infra/ansible/vars/global.yml
  - "/srv/private/ansible/vars.yml"
  - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  roles:
  - base
  - hosts
  - rkhunter
  - nagios_client
  - fas_client
  - collectd/base
  - sudo
  - apache
  - gitolite/base
  - cgit/base
  - cgit/clean_lock_cron
  - cgit/make_pkgs_list
  - gitolite/check_fedmsg_hooks
  - { role: git/make_checkout_seed, when: env != "staging" }
  - git/server
  - git/hooks
  - git/checks
  - clamav
  - { role: nfs/client,
      when: env != "staging",
      mnt_dir: '/srv/cache/lookaside',
      nfs_src_dir: 'fedora_sourcecache', nfs_mount_opts='rw,hard,bg,intr,noatime,nodev,nosuid,sec=sys,nfsvers=3' }
  - { role: nfs/client,
      when: env == "staging" and inventory_hostname.startswith('pkgs02'),
      mnt_dir: '/srv/cache/lookaside_prod',
      nfs_src_dir: 'fedora_sourcecache', nfs_mount_opts='ro,hard,bg,intr,noatime,nodev,nosuid,sec=sys,nfsvers=3' }
  - role: distgit/pagure
  - role: distgit
    tags: distgit
  - { role: hosts, when: env == "staging" }

  tasks:
  - name: Copy keytab
    copy: src={{private}}/files/keytabs/{{env}}/pkgs
          dest=/etc/httpd.keytab
          owner=apache group=apache mode=0600
    tags:
    - krb5

  - import_tasks: "{{ tasks_path }}/yumrepos.yml"
  - import_tasks: "{{ tasks_path }}/motd.yml"
  - import_tasks: "{{ tasks_path }}/2fa_client.yml"

  handlers:
  - import_tasks: "{{ handlers_path }}/restart_services.yml"

- name: setup fedmsg on pkgs
  hosts: pkgs-stg:pkgs02.phx2.fedoraproject.org
  user: root
  gather_facts: True

  vars_files:
  - /srv/web/infra/ansible/vars/global.yml
  - "/srv/private/ansible/vars.yml"
  - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  roles:
  - { role: collectd/fedmsg-service, process: fedmsg-hub }
  - fedmsg/base
  - fedmsg/hub

  handlers:
  - import_tasks: "{{ handlers_path }}/restart_services.yml"
